package com.adnaan.backend.mapper;

import com.adnaan.backend.entity.ViewHistory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface ViewHistoryMapper extends BaseMapper<ViewHistory> {
    /**
     * 统计指定时间范围内每天的浏览量
     */
    @Select("SELECT DATE(view_time) as date, COUNT(*) as count FROM user_view_history " +
            "WHERE view_time BETWEEN #{startTime} AND #{endTime} " +
            "GROUP BY DATE(view_time)")
    List<Map<String, Object>> countGroupByDate(LocalDateTime startTime, LocalDateTime endTime);
} 